﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace C2E2C.Web.ViewModels
{
    [MetadataType(typeof(UserRegisterModelMetadata))]
    public partial class UserRegisterModel
    {
        class UserRegisterModelMetadata
        {
            [Required(
                ErrorMessageResourceName = "RegisterModel_Email_Required", 
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
                ErrorMessageResourceName = "RegisterModel_Email_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "验证E-mail：")]
            public string Email { get; set; }

            [Required(ErrorMessageResourceName = "RegisterModel_UserName_Required",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [StringLength(20, MinimumLength = 3,
                ErrorMessageResourceName = "RegisterModel_UserName_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "用户ID：")]
            public string UserName { get; set; }

            [Required(
                ErrorMessageResourceName = "RegisterModel_RealName_Required",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "姓名：")]
            public string RealName { get; set; }

            [Required(ErrorMessageResourceName = "RegisterModel_Password_Required",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [StringLength(20, MinimumLength = 6,
                ErrorMessageResourceName = "RegisterModel_Password_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [DataType(DataType.Password)]
            [Display(Name = "密码：")]
            public string Password { get; set; }

            [DataType(DataType.Password)]
            [Compare("Password",
                ErrorMessageResourceName = "RegisterModel_ConfirmPassword_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "确认密码：")]
            public string ConfirmPassword { get; set; }

            [Required(ErrorMessageResourceName = "RegisterModel_Company_Required",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [StringLength(64, MinimumLength=4,
                ErrorMessageResourceName = "RegisterModel_Company_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "公司/学校：")]
            public string Company { get; set; }

            [Required(ErrorMessageResourceName = "RegisterModel_Phone_Required",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [RegularExpression("^[0-9]{11}$",
                ErrorMessageResourceName = "RegisterModel_Phone_Invalid",
                ErrorMessageResourceType = typeof(Resources.ModelMetadata))]
            [Display(Name = "主要电话：")]
            public string Phone { get; set; }
        }
    }
}